]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Introduce singleton Source for system notifications
authorJulian Sparber <julian@sparber.net>
Tue, 30 Jan 2024 17:04:36 +0000 (18:04 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 6 Feb 2024 17:25:01 +0000 (17:25 +0000)
This `Source` object should be used by all notifications created by
GNOME Shell and eventually can also be used by extensions.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3156>

js/ui/messageTray.js

index 479044a3adbe30896038bb2126211599c7fb28a6..a069f16d4d15f584e6e3001d700f0ce1eaed0a47 100644 (file)
@@ -1326,6 +1326,29 @@ export const MessageTray = GObject.registerClass({
     }
 });
 
+let systemNotificationSource = null;
+
+/**
+ * The {Source} that should be used to send system notifications.
+ *
+ * @returns {Source}
+ */
+export function getSystemSource() {
+    if (!systemNotificationSource) {
+        systemNotificationSource = new Source({
+            title: _('System'),
+            iconName: 'emblem-system-symbolic',
+        });
+
+        systemNotificationSource.connect('destroy', () => {
+            systemNotificationSource = null;
+        });
+        Main.messageTray.add(systemNotificationSource);
+    }
+
+    return systemNotificationSource;
+}
+
 export const SystemNotificationSource = GObject.registerClass(
 class SystemNotificationSource extends Source {
     constructor() {